home *** CD-ROM | disk | FTP | other *** search
/ The Sunday Times: The Month 2003 December / The Sunday Times - The Month 2003-12.iso / mac / The Month DEC 03 / engine / modules / preview_fader.swf / scripts / frame_7 / DoAction.as
Text File  |  2003-11-10  |  4KB  |  168 lines

  1. function loadImage(mc, node, extrapath)
  2. {
  3.    extrapath != null ? 0 : (extrapath = "");
  4.    var strDefaultPath = Tardis.ASSETS_FOLDER + "images/" + Tardis.ActiveSection.id + "/";
  5.    var strImg = node.firstChild.nodeValue;
  6.    var diffpath = node.attributes.path;
  7.    if(diffpath != null)
  8.    {
  9.       strImg = diffpath + strImg;
  10.    }
  11.    else
  12.    {
  13.       strImg = strDefaultPath + extrapath + strImg;
  14.    }
  15.    strPathPrefix != null ? 0 : (strPathPrefix = "");
  16.    mc.loadMovie(strPathPrefix + strImg);
  17. }
  18. function old()
  19. {
  20.    trace("preview_fader.old()");
  21.    nmCurrentImage = 0;
  22.    PREVIEW_PATH = nodeData.attributes.imagepath;
  23.    nmImagesTotal = nodeData.childNodes.length;
  24.    nmImageNextLoad = 0;
  25.    loadNext();
  26. }
  27. function doOver(num)
  28. {
  29.    trace("preview_fader.doOver(" + num + ")");
  30.    fade = false;
  31.    clearFadeDelay();
  32.    mc_back._visible = false;
  33.    mc_front._visible = false;
  34.    mc_front.onEnterFrame = null;
  35.    nmCurrentImage = num;
  36.    showCurrentImage();
  37.    updateAfterEvent();
  38. }
  39. function doOut(num)
  40. {
  41.    trace("preview_fader.doOut(" + num + ")");
  42.    if(!_parent.autoPlayingTracks)
  43.    {
  44.       fade = true;
  45.       clearFadeDelay();
  46.       nmCurrentImage = num;
  47.       updateAfterEvent();
  48.       if(num == "initial")
  49.       {
  50.          nmCurrentImage = 0;
  51.          fadeAfterPause();
  52.       }
  53.       else
  54.       {
  55.          fadeNext();
  56.       }
  57.    }
  58.    else
  59.    {
  60.       _parent.doOver(_parent.myPlayList.currArtistId);
  61.    }
  62. }
  63. function loadNext()
  64. {
  65.    trace("preview_fader.loadNext() .. nmImageNextLoad= " + nmImageNextLoad);
  66.    if(nmImageNextLoad == nmImagesTotal)
  67.    {
  68.       delete nmImageNextLoad;
  69.       preview_fader.doOut("initial");
  70.    }
  71.    else
  72.    {
  73.       var mc_image = this.createEmptyMovieClip("mc_image_" + nmImageNextLoad,++depth);
  74.       if(nmImageNextLoad != 0)
  75.       {
  76.          mc_image._visible = false;
  77.       }
  78.       var mc_file = mc_image.createEmptyMovieClip("mc_file",++depth);
  79.       mc_file.onLoad = fileLoaded;
  80.       loadImage(mc_file,nodeData.childNodes[nmImageNextLoad].byName("image"),PREVIEW_PATH);
  81.       nmImageNextLoad++;
  82.    }
  83. }
  84. function showCurrentImage()
  85. {
  86.    trace("preview_fader.showCurrentImage() .. nmCurrentImage=" + nmCurrentImage);
  87.    mc_back = this["mc_image_" + nmCurrentImage];
  88.    mc_back._alpha = 100;
  89.    mc_back._visible = true;
  90. }
  91. function fileLoaded()
  92. {
  93.    trace("preview_fader.fileLoaded()");
  94.    this.onLoad = null;
  95.    if(nmImageNextLoad == nmImagesTotal)
  96.    {
  97.       this["mc_image_" + nmCurrentImage]._visible = true;
  98.       fadeAfterPause();
  99.       onComplete();
  100.    }
  101.    else
  102.    {
  103.       loadNext();
  104.    }
  105. }
  106. function fadeAfterPause()
  107. {
  108.    trace("preview_fader.fadeAfterPause()");
  109.    nmFadeIntervalID = setInterval(fadeNext,FADE_DELAY);
  110. }
  111. function clearFadeDelay()
  112. {
  113.    trace("preview_fader.clearFadeDelay()");
  114.    clearInterval(nmFadeIntervalID);
  115. }
  116. function fadeNext()
  117. {
  118.    trace("preview_fader.fadeNext() fade=" + fade + " nmCurrentImage=" + nmCurrentImage);
  119.    if(fade)
  120.    {
  121.       clearFadeDelay();
  122.       mc_back = this["mc_image_" + nmCurrentImage];
  123.       var nmFront = nmCurrentImage != nmImagesTotal - 1 ? parseInt(nmCurrentImage) + 1 : 0;
  124.       mc_front = this["mc_image_" + nmFront];
  125.       mc_front._alpha = 0;
  126.       mc_front._visible = true;
  127.       showCurrentImage();
  128.       if(mc_back.getDepth() > mc_front.getDepth())
  129.       {
  130.          mc_back.swapDepths(mc_front);
  131.       }
  132.       mc_front.onEnterFrame = function()
  133.       {
  134.          this._alpha += FADE_INCREMENT;
  135.          if(this._alpha >= 100)
  136.          {
  137.             this._alpha = 100;
  138.             this.onEnterFrame = null;
  139.             fadeFinished();
  140.          }
  141.       };
  142.    }
  143. }
  144. function fadeFinished()
  145. {
  146.    trace("preview_fader.fadeFinished()");
  147.    mc_back._visible = false;
  148.    if(nmCurrentImage >= nmImagesTotal - 1)
  149.    {
  150.       nmCurrentImage = 0;
  151.    }
  152.    else
  153.    {
  154.       nmCurrentImage++;
  155.    }
  156.    fadeAfterPause();
  157. }
  158. FADE_INCREMENT = 4;
  159. FADE_DELAY = 3000;
  160. nmImagesLoaded = 0;
  161. fade = true;
  162. depth = 0;
  163. this.onUnload = function()
  164. {
  165.    clearFadeDelay();
  166.    mc_front.onEnterFrame = null;
  167. };
  168.